//draw a rect with texture.
//require Primitive is TriangleStrip 
//do not need to set vertex buffer

#version 460
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable


layout (push_constant) uniform SImageItemVertexPushConstant
{

   vec2 LeftTopPosition;
   vec2 RightBottomPosition;  

   float ZOrder;

} PushConstants;

layout (location = 0) out vec2 outUV;

void main() 
{
   /*
      V0                   V1
      ---------------------
      |                   |
      |                   |
      |                   |
      |                   |
      |                   |
      ---------------------
      V2                   V3
   */



   vec2 Position[4];
   Position[0]=PushConstants.LeftTopPosition;
   Position[1]=vec2(PushConstants.RightBottomPosition.x,PushConstants.LeftTopPosition.y);
   Position[2]=vec2(PushConstants.LeftTopPosition.x,PushConstants.RightBottomPosition.y);
   Position[3]=PushConstants.RightBottomPosition;

   gl_Position =vec4(Position[gl_VertexIndex],PushConstants.ZOrder ,1);

   vec2 UV[4];

   UV[0]=vec2(0,0);
   UV[1]=vec2(1,0);
   UV[2]=vec2(0,1);
   UV[3]=vec2(1,1);
   
   outUV=UV[gl_VertexIndex];
}